RecoBundles80 using AFQ API#

An example using the AFQ API to run recobundles with the 80 bundle atlas.

import os.path as op

import plotly

from AFQ.api.group import GroupAFQ
import AFQ.data.fetch as afd

Get some example data#

Retrieves Stanford HARDI dataset.

afd.organize_stanford_data(clear_previous_afq="track")

Set tractography parameters (optional)#

We make this tracking_params which we will pass to the GroupAFQ object which specifies that we want 10,000 seeds randomly distributed in the white matter.

We only do this to make this example faster and consume less space.

tracking_params = dict(n_seeds=10000,
                       random_seeds=True,
                       rng_seed=42)

Initialize a GroupAFQ object:#

We specify seg_algo as reco80 in segmentation_params. This tells the AFQ object to perform RecoBundles using the 80 bundles atlas in the segmentation step.

myafq = GroupAFQ(bids_path=op.join(afd.afq_home,
                                   'stanford_hardi'),
                 preproc_pipeline='vistasoft',
                 segmentation_params={"seg_algo": "reco80"},
                 tracking_params=tracking_params)
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/bids/layout/validation.py:122: UserWarning:

The PipelineDescription field was superseded by GeneratedBy in BIDS 1.4.0. You can use ``pybids upgrade`` to update your derivative dataset.

Visualizing bundles and tract profiles:#

This would run the script and visualize the bundles using the plotly interactive visualization, which should automatically open in a new browser window.

bundle_html = myafq.export("all_bundles_figure")
plotly.io.show(bundle_html["01"][0])

Total running time of the script: (13 minutes 41.682 seconds)

Estimated memory usage: 3155 MB

Gallery generated by Sphinx-Gallery